<%@ page import="java.util.Enumeration"%>
<%@ page import="java.util.Collection"%>
<%@ page import="org.springframework.prospring.ticket.domain.Club"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
<%@ taglib uri="/WEB-INF/tld/struts-tiles.tld" prefix="tiles" %>

<html>
    <head>
        <title>Seats reserved for <c:out value="${performance.show.name}"/></title>
    </head>


<%
Enumeration  e = request.getAttributeNames();
    while (e.hasMoreElements()) {
        String attirbuteName = (String) e.nextElement();

        System.out.println("###############################  attirbuteName = " + attirbuteName);

    }

    Collection myClubs = (Collection) request.getAttribute("clubs");
    if (myClubs != null) {
        for (java.util.Iterator iterator = myClubs.iterator(); iterator.hasNext();) {
            Club club = (org.springframework.prospring.ticket.domain.Club) iterator.next();
            System.out.println("club.getId() = " + club.getId());
        }
    }

%>
<script language="JavaScript" type="text/javascript">

    function submitReservationFieldRequestForm5(regionId, clubId, fieldId, reservationDate, startHour, endHour) {
            //var form = document.getElementById("submitReservationFieldRequestForm5");
        var form = document.forms["nameReservationFieldRequestForm5"];
        form.regionId.value = regionId;
        form.clubId.value = clubId;
        form.fieldId.value = fieldId;
        form.reservationDate.value = reservationDate;
        form.startHour.value = startHour;
        form.endHour.value = endHour;
        form.submit();
	}

</script>
<body>

<!-- before insert reservationSearchForm -->
<tiles:insert attribute="reservationSearchForm"/>
<!-- after insert reservationSearchForm -->



<%-- ====== Begin: DATOS DEL CLUB =============================--%>
<c:choose>
    <c:when test="${not empty clubSelected}">
        <table id="tbl_sedes" align="center" border="1" bordercolor="#006600" cellpadding="2" cellspacing="0" height="250" width="350">
        <tbody>
            <tr>
                <th scope="col"><c:out value="${clubSelected.id}"/> - <c:out value="${clubSelected.name}"/></th>
            </tr>
            <tr>
                <td>Canchas de Futbol - Escuela - Gimnasio - Buffet</td>
            </tr>
            <tr>
                <td>4866-4047 / 4862-9386/9392</td>
            </tr>
            <tr>
                <td>Mail: <c:out value="${clubSelected.mail}"/></td>
            </tr>
            <tr>
                <td>Gallo 241</td>
            </tr>
            <tr>
                <td>Horario : 08 a 22 hs</td>
            </tr>
            <tr>
                <td height="17">Como llegar<br>xxxx</td>
            </tr>
            <tr>
                <td>
                    <table border="1" bordercolor="#006600" cellpadding="1" cellspacing="0" height="100%" width="100%">
                        <tbody><tr>
                            <th scope="col" width="175">Estacionamiento</th>
                            <th scope="col" width="178">Buffet/Bebidas</th>
                        </tr>
                            <tr>
                                <td><div align="center">SI</div></td>
                                <td><div align="center">SI</div></td>
                            </tr>
                        </tbody>
                    </table>
                </td>
            </tr>
        </tbody>
        </table>

    </c:when>
    <c:otherwise>
        <!-- selected club is empty -->
    </c:otherwise>
</c:choose>
<%-- ====== END: DATOS DEL CLUB =============================--%>



<div id="fieldsContainer">
    <form id="reservationFieldRequestForm5" name="nameReservationFieldRequestForm5" action="reserveFieldStep5.html" method="GET">
        <input type="hidden" name="regionId"/>
        <input type="hidden" name="clubId"/>
        <input type="hidden" name="fieldId"/>
        <input type="hidden" name="reservationDate"/>
        <input type="hidden" name="startHour"/>
        <input type="hidden" name="endHour"/>

        ====
        <fmt:formatDate value="${reservationFieldRequest.reservationDate}"  type="date" dateStyle="full"/>
        ====
        <table id="tbl_fields" align="center" border="1" bordercolor="#006600" cellpadding="2" cellspacing="0" height="250" width="500">
        <tbody>
            <tr>
                <th scope="col">Seleccione</th>
                <th scope="col">Cant. Jug. </th>
                <th scope="col">Reservado por</th>
                <th scope="col">Techada</th>
                <th scope="col">Disponible</th>
            </tr>
        <c:forEach items="${turns}" var="turn">
<%--
            <c:if test="${not empty club.name}">
--%>
                <tr>
                    <td>
                        <c:choose>
                            <c:when test="${turn.available}" >
                                <a href="javascript:submitReservationFieldRequestForm5(<c:out value="${reservationFieldRequest.regionId}"/>, <c:out value="${reservationFieldRequest.clubId}"/>, <c:out value="${reservationFieldRequest.fieldId}"/>, '<fmt:formatDate value="${reservationFieldRequest.reservationDate}" type="date" dateStyle="medium"/>', '<fmt:formatDate value="${turn.startDate}" type="date" pattern="HH_mm"/>', '<fmt:formatDate value="${turn.endDate}" type="date" pattern="HH_mm"/>');">
                                    Reservar
                                </a>
                            </c:when >
                            <c:otherwise>
                                <!-- Not available-->
                            </c:otherwise >
                        </c:choose>
                    </td>
                    <td> NNN </td>
                    <td>
                        <c:choose>
                            <c:when test="${!empty turn.user}" >
                                <c:out value="${turn.user.nickname}"/>
                            </c:when >
                            <c:otherwise>
                                Turn available
                            </c:otherwise >
                        </c:choose>                    </td>
                    <td>
                        <fmt:formatDate value="${turn.startDate}" type="date" pattern="HH:mm"/> -
                        <fmt:formatDate value="${turn.endDate}" type="date" pattern="HH:mm"/>
                    </td>
                    <td>

                        <c:out value="${turn.available}"/>
                        <c:out value="${reservationFieldRequest.reservationDate}"/>
                        <fmt:formatDate value="${reservationFieldRequest.reservationDate}"  type="date" dateStyle="medium"/>
                       <c:choose>
                            <c:when test="${turn.available}" >
                                <a href="<%=request.getContextPath()%>/reserveFieldStep5.html?regionId=<c:out value="${reservationFieldRequest.regionId}"/>&clubId=<c:out value="${reservationFieldRequest.clubId}"/>&fieldId=<c:out value="${reservationFieldRequest.fieldId}"/>&reservationDate=<fmt:formatDate value="${reservationFieldRequest.reservationDate}"  type="date" dateStyle="medium"/>">
                                    Reservar
                                </a>
                            </c:when >
                            <c:otherwise>
                                <!-- Not available-->
                            </c:otherwise >
                        </c:choose>
                    </td>
                </tr>
                <p/>
<%--
            </c:if>
--%>
        </c:forEach>

        </tbody>
        </table>

    </form>
</div>
<%--
        <b><c:out value="${performance.show.name}"/>:
        <fmt:formatDate value="${performance.dateAndTime}" type="date" pattern="EEEE MMMM dd, yyyy"/>
        </b>
        <br/>
        <p/>

        <c:out value="${seatsCount}" />
        seats have been reserved for you for
        <c:out value="${minutesReservationWillBeValid}" />
        minutes to give you time to complete your purchase.
        The seat numbers are

        <ul>
        <c:forEach items="${reservation.seats}" var="seat">
            <li><c:out value="${seat.name}"/></li>
        </c:forEach>
        </ul>


        <p/>
        The total cost of these tickets will be
        <fmt:formatNumber value="${reservation.booking.price}" type="currency"/>.
        This includes a booking fee of
        <fmt:formatNumber value="${bookingFee}" type="currency"/>.

        <p/>

        <c:if test="${!seatsAdjacent}" >
            <b>Please note that due to lack of availability, some of the
            seats offered are not adjacent.</b>
        </c:if>

        <table>

            <tr>

                <td>
                    <form method="GET" action="displayShow.html">
                        <input type="hidden" name="showId" value="<c:out value="${performance.show.id}"/>"/>
                        <c:choose>
                            <c:when test="${!seatsAdjacent}" >
                                <input type="submit" value="Try another date"/>
                            </c:when >
                            <c:otherwise>
                                <input type="submit" value="Cancel"/>
                            </c:otherwise >
                        </c:choose>
                    </form>
                </td>

                <td>
                    <form method="GET" action="payment.html">
                        <input type="hidden" name="bookingId" value="<c:out value="${reservation.booking.id}"/>"/>
                        <input type="hidden" name="performanceId" value="<c:out value="${performance.id}"/>"/>
                        <input type="submit" value="Proceed"/>
                    </form>

                </td>

            </tr>

        </table>
--%>

</body>

</html>


<!-- ************************************************ -->
<!-- pageName: formReservationFieldStep4.jsp          -->
<!-- ************************************************ -->
